<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" class="x-admin-sm">

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.4.1.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
    <script src="/js/dateFormat.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>

    <![endif]-->
</head>

<body>
<div class="layui-fluid">
    <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a>订单管理</a>
                <a>
                    <cite>订单列表</cite></a>
            </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>

    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-collapse">
                <div class="layui-card">
                    <div class="layui-card-header">
                        <div class="layui-form">
                            <div class="layui-inline">
                                <div class="layui-input-inline" style="width: 100px;">
                                    <button type="button" onclick="location.href='/self/addCommodity'"
                                            class="layui-btn layui-btn-radius"><i
                                            class="layui-icon">&#xe615;</i>上架商品
                                    </button>
                                </div>


                            </div>
                        </div>

                    </div>
                    <div class="layui-card-body">
                        <table class="layui-table"
                               lay-data="{height:500, url:'/Ajax/admin/commodity/myList', method:'post', contentType: 'application/json', page:true, id:'test', align:'center'}"
                               lay-filter="test">
                            <thead>
                            <tr>
                                <th lay-data="{field:'id', width:80, sort: true}">ID</th>
                                <th lay-data="{field:'name'}">商品名</th>
                                <th lay-data="{templet:'#time'}">上架时间</th>
                                <th lay-data="{templet:'#status'}">状态</th>
                                <th lay-data="{templet:'#show'}">查看</th>
                            </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>

        </div>
    </div>
</div>
<script>
    var table

    layui.use('table', function () {
        table = layui.table;
    });


    function doSearch() {
        var json = {}
        json.name = $("#input").val()
        table.reload("test", {
            url: '/Ajax/admin/commodity/myList',
            method: 'post',
            contentType: 'application/json',
            where: json
        })
    }
</script>

<script type="text/html" id="time">
    {{ FormatDate(d.registerdate)}}
</script>

<script type="text/html" id="life">
    {{ FormatDate(d.start)}} - {{ FormatDate(d.end)}}
</script>

<script type="text/html" id="type">
    {{# if(d.type == 1){}}
    个体
    {{# } else if(d.type == 2){ }}
    公司集团
    {{# } }}
</script>

<script type="text/html" id="status">
    {{# if(d.status == 1){}}
    上架
    {{# } else if(d.status == 2){ }}
    下架
    {{# } }}
</script>
<script type="text/html" id="show">
    {{# if(d.status == 1){}}
    <input class="layui-btn layui-btn-danger" type="button" value="下架"
           onclick="location.href='/self/commodity/save?id={{d.id}}&status=2'"/>
    {{# }}}
    {{# if(d.status == 2){}}
    <input class="layui-btn layui-btn-danger" type="button" value="上架"
           onclick="location.href='/self/commodity/save?id={{d.id}}&status=1'"/>
    {{# }}}
</script>
</body>
</html>